package graph_algorithms;

/**
 * author :  apurv verma
 * email  :  dapurv5@gmail.com
 */


/*
* UTILITY: Can find the shortest path from the source cell to the goal cell in a 2d and 3d maze.
*/


public class MAIN {
	
	//USAGE
	
	public static void main(String args[]){
		
		//1.FIRST CREATE A GRAPH
		double graph[][]={{0,1,5,-1,-1},{1,0,-1,1,1},{5,-1,0,1,1},{-1,1,1,0,-1},{-1,3,1,-1,0}};
		Graph g=new Graph(graph);
		
		//2. CREATE AN OBJECT OF Dijikstra class WITH g PASSED INTO THE CONSTRUCTOR.
		Dijikstra d=new Dijikstra(g);
		d.dijikstrasShortestPath(0,4);
		
		//3. THE PATH CAN BE FOUND BY FOLLOWING d.predecessor[4] TO THE STARTING VERTEX.
		System.out.println();
		
		
		//4. FOR KRUKSALS ALGORITHM.
		KruksalsAlgorithm ks=new KruksalsAlgorithm(g);
		ks.shortestSpanningTree();
		
		//5.TO GET THE SPANNING TREE, WHICH IS RETURNED AS AN ARRAY OF DIMENSION.
		System.out.println("\nThe spanning tree is:");
		for(int i=0;i<ks.spanTree.length;i++){
			System.out.println(ks.spanTree[i].height+" , "+ks.spanTree[i].width);
		}
		//6. TO GET THE LENGTH OF THE SPANNING TREE
		System.out.println("\nIts length is ="+ks.lenSpanTree);
		
		
		
	}

}
